////////////////////////////////////////////////////////////////////////////////
//
//	Original file Name: Mob.java
//	Originating Author: JWhitefield
//	
//	Description: Moving Entitys within the game world
//
////////////////////////////////////////////////////////////////////////////////

package com.jjw.game.world.entity.character;

import java.awt.Graphics;

/**
 * Moving Entity's within the game world
 * @author JWhitefield
 *
 */
public class Mob extends Entity {
	
	//--------------------------------------------------------------------------
	//
	//Properties
	//
	//--------------------------------------------------------------------------
	
	//----------------------------------
	// Public
	//----------------------------------
	
	//----------------------------------
	//  Getters / Setters
	//----------------------------------
	
	/**
	 * Get the direction of the Mob
	 * @return
	 */
	public int getDirection() {
		return direction;
	}

	/**
	 * Set the direction of the Mob
	 * @return
	 */
	protected void setDirection(int direction) {
		this.direction = direction;
	}

	/**
	 * Get the walking distance of the Mob
	 * @return
	 */
	public int getWalkDistance() {
		return walkDistance;
	}

	/**
	 * Set the direction of the Mob
	 * @return
	 */
	protected void setWalkDistance(int walkDistance) {
		this.walkDistance = walkDistance;
	}

	/**
	 * Get the knock back x of the Mob
	 * @return
	 */
	public int getxKnockback() {
		return xKnockback;
	}

	/**
	 * Set the knock back x of the Mob
	 * @return
	 */
	protected void setxKnockback(int xKnockback) {
		this.xKnockback = xKnockback;
	}

	/**
	 * Get the knock back y of the Mob
	 * @return
	 */
	public int getyKnockback() {
		return yKnockback;
	}

	/**
	 * Set the knock back y of the Mob
	 * @return
	 */
	protected void setyKnockback(int yKnockback) {
		this.yKnockback = yKnockback;
	}
	
	//----------------------------------
	// Private
	//----------------------------------
	
	/**
	 * Direction the mob is facing 
	 */
	private int direction = 0;
	
	/**
	 * The Distance the player has walked 
	 */
	private int walkDistance = 0;
	
	/**
	 * Knock back variables so players can be knocked backwards 
	 */
	private int xKnockback, yKnockback;
	
	//--------------------------------------------------------------------------
	//
	//  Methods
	//
	//--------------------------------------------------------------------------
	
	//----------------------------------
	// Public
	//----------------------------------
	
	/**
	 * Constructor which sets the mod's default postion 
	 */
	public Mob() {
		
		//Set the default x and y chord
		this.setX(8);
		this.setY(8);
		
		//Set the rotation 
		this.setXr(4);
		this.setYr(3);
	}
	
	/**
	 * Called to kill the mob
	 */
	public void die(){
		//Set the mob to be removed 
		this.remove();
	}
	
	
	//----------------------------------
	// Private
	//----------------------------------
	
	//----------------------------------
	// Overriden / Implmented
	//----------------------------------
	
	@Override
	/**
	 * Used to move the mob
	 */
	public boolean move( int xa, int ya ){
		
		//Check that the axis are zero
		if (xa != 0 || ya != 0) {
			
			//As we are walking up the distance we have walked
			this.walkDistance++;
			
			//Set the direction the mob is moving 
			if (xa < 0){ 
				this.direction = 2;
			}
			if (xa > 0){
				this.direction = 3;
			}
			if (ya < 0){
				this.direction = 1;
			}
			if (ya > 0){
				this.direction = 0;
			}
		}
				
		//Call the mobs super move to actually move the entity 
		return super.move(xa, ya);
	}
}
